#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package}.common.util;

import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;

/**
 * Created by well on 17/8/7.
 */
public class PriceUtil {

    /**
     * 将分为单位的字符串或者对象格式化为元为单位的金额字符串,其他更低精度的转为元会丢失精度
     * @param value
     * @return
     */
    public static String formatCNY(Object value) {
        if (value == null) {
            return null;
        }
        NumberFormat formatter = NumberFormat.getNumberInstance(Locale.CHINA);
        formatter.setMaximumFractionDigits(2);
        try {
            return String.valueOf(formatter.parse(String.valueOf(Long.parseLong(String.valueOf(value)) / 100.00)));
        } catch (ParseException e) {
        }
        return null;

    }

}
